package Review2;

public class Test16 {
    public ListNode reverseList(ListNode head){
    	if(head==null||head.next==null){
    		return head;
    	}
    	ListNode pre = head;
    	ListNode p = head.next;
    	head.next=null;
    	while(p!=null){
    		ListNode nxt = p.next;
    		p.next=pre;
    		p=nxt;
    		pre=p;
    	}
    	return pre;
    }
}
